import java.util.Scanner;

public class factorialsum {
    public static void main(String[] args) {
        System.out.println("求1！+2！+3！+4！+........+n!的和");
        System.out.print("n=");
        Scanner num = new Scanner(System.in);
        int n = num.nextInt();
        int j = 1;
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            j *= i;
            sum += j;
        }
        System.out.println("合为"+sum);
    }
}
